//
//  TravelViewCell.m
//  XhlTrip
//
//  Created by dllo on 15/8/21.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "TravelViewCell.h"
#import "UIImageView+WebCache.h"
#import "TravelModel.h"
@implementation TravelViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.MaxImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.MaxImageView];
        [_MaxImageView release];
        
        
        self.SmallImageView = [[UIImageView alloc] init];
        [self.MaxImageView addSubview:_SmallImageView];
        [_SmallImageView release];
        _SmallImageView.layer.cornerRadius = 5;
        _SmallImageView.layer.borderWidth = 2.5;
        _SmallImageView.layer.borderColor = [UIColor whiteColor].CGColor;
        
        
        self.nameLabel = [[UILabel alloc] init];
        _nameLabel.numberOfLines = 2;
        [_MaxImageView addSubview:_nameLabel];
        
        
        self.datalabel = [[UILabel alloc] init];
        [self.MaxImageView addSubview:_datalabel];
        [_datalabel release];
        
        self.daysLabel = [[UILabel alloc] init];
        [self.MaxImageView addSubview:_daysLabel];
        [_daysLabel release];
        
        self.pCountLabel = [[UILabel alloc] init];
        [self.MaxImageView addSubview:_pCountLabel];
        [_pCountLabel release];
        
        _daysLabel.textColor = [UIColor whiteColor];
        _daysLabel.highlighted = YES;
        _daysLabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:14 * Width];
        
        _pCountLabel.textColor = [UIColor whiteColor];
        _pCountLabel.highlighted = YES;
        _pCountLabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:14 * Width];
        
        _datalabel.textColor = [UIColor whiteColor];
        _datalabel.highlighted = YES;
        _datalabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:14 * Width];
        
        _nameLabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:20 * Width];
        _nameLabel.textColor = [UIColor whiteColor];
        _nameLabel.highlighted = YES;
 

            }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.MaxImageView.frame = CGRectMake(10 * Width, 0, self.contentView.frame.size.width - 20 * Width, 200 * Height);
    self.SmallImageView.frame = CGRectMake(10 * Width, 155 * Height, 35 * Width, 35 * Height);
    self.nameLabel.frame = CGRectMake(10 * Width, 0, self.MaxImageView.frame.size.width - 20 * Width, 60 * Height);
    self.datalabel.frame = CGRectMake(10 * Width, 60 * Height, 100 * Width, 25 * Height);
    self.daysLabel.frame = CGRectMake(110 * Width, 60 * Height, 50 * Width, 25 * Height);
    self.pCountLabel.frame = CGRectMake(160 * Width, 60 * Height, 50 * Width, 25 * Height);
}

- (void)dealloc
{
    [_travelModel release];
    [_MaxImageView release];
    [_SmallImageView release];
    [_nameLabel release];
    [_datalabel release];
    [_daysLabel release];
    [_pCountLabel release];
    [super dealloc];
    
}


/* 重写set方法 用model给控件赋值 */
-(void)setTravelModel:(TravelModel *)travelModel
{
    if (_travelModel != travelModel) {
        [_travelModel release];
        _travelModel = [travelModel retain];
    }
    [_MaxImageView sd_setImageWithURL:travelModel.front_cover_photo_url];
    _nameLabel.text = travelModel.name;
    _datalabel.text = travelModel.start_date;
    _daysLabel.text =[NSString stringWithFormat:@"%@%@", [travelModel.days stringValue], @"天"];
    _pCountLabel.text =[ NSString stringWithFormat:@"%@%@", [travelModel.photos_count stringValue], @"图"];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
